import 'package:flutter_app/class/MyApp3.dart';
import 'package:flutter/material.dart';

class MyApp4 extends StatelessWidget {
  const MyApp4({super.key});

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return const MaterialApp(home: StatefullsApp());
  }
}

class StatefullsApp extends StatefulWidget {
  const StatefullsApp({super.key});

  @override
  State<StatefullsApp> createState() => MyApp4State();
}

class MyApp4State extends State<StatefullsApp> {

  final _arrImags = [
    'https://img0.baidu.com/it/u=1245289446,2880955601&fm=253&fmt=auto&app=138&f=JPEG?w=738&h=500',
    'https://img1.baidu.com/it/u=2112983391,1109793557&fm=253&fmt=auto&app=138&f=JPEG?w=620&h=415',
    'https://img2.baidu.com/it/u=3817318593,2091473746&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=750',
    'https://img1.baidu.com/it/u=790071339,2960147358&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
    'https://img0.baidu.com/it/u=3514137255,3208117610&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
    'https://img1.baidu.com/it/u=534886884,760676900&fm=253&fmt=auto&app=120&f=JPEG?w=640&h=960',
    'https://img2.baidu.com/it/u=160668730,1583519870&fm=253&fmt=auto&app=138&f=JPEG?w=776&h=500',
    'https://img2.baidu.com/it/u=3155922605,3536500718&fm=253&fmt=auto&app=138&f=JPEG?w=640&h=483',
    'https://img2.baidu.com/it/u=2335640038,887495413&fm=253&fmt=auto&app=120&f=JPEG?w=1200&h=800',
    'https://img2.baidu.com/it/u=595145732,4213010578&fm=253&fmt=auto&app=120&f=JPEG?w=1200&h=800',
    'https://img2.baidu.com/it/u=34635369,1700394341&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1717520400&t=1090a72e239bac200595bc824ecae73e'
  ];

 List<Widget> getChildren(){
    var list = <Widget>[];
    for(int i = 0,len = _arrImags.length - 1; i < len; i+=2){
       list.add(
         Row(
           children: <Widget>[
             Expanded(
               child: Container(
                 margin: const EdgeInsets.all(4.0),
                 decoration: BoxDecoration(
                     border: Border.all(
                         width: 10.0, color: Colors.black38),
                     borderRadius:
                     const BorderRadius.all(Radius.circular(8.0))),
                 child: Image.network(_arrImags[i]),
               ),
             ),
             Expanded(
                 child: Container(
               margin: const EdgeInsets.all(4.0),
               decoration: BoxDecoration(
                   border: Border.all(
                       width: 10.0, color: Colors.black38),
                   borderRadius:
                   const BorderRadius.all(Radius.circular(8.0))),
               child: Image.network(_arrImags[i+1]),
             )
             ),
           ],
         )
       );
    }

    return list;
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: "样式Demo4",
      home: Scaffold(
        appBar: AppBar(
          title: const Text(
            '样式Demo4',
            style: TextStyle(fontSize: 18.0),
          ),
          actions: <Widget>[
             IconButton(
                icon: const Icon(Icons.arrow_right),
                onPressed: () {
                  Navigator.of(context).push(
                    MaterialPageRoute(builder: (context) {
                      return const MyApp3();
                    }),
                  );
                }
             ),
          ],
        ),
        body: SingleChildScrollView(
          child: Column(
            mainAxisSize: MainAxisSize.max,
            children: getChildren(),
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            Navigator.of(context).pop();
          },
          child: const Icon(Icons.replay),
        ),
      ),
      theme: ThemeData(primaryColor: Colors.redAccent),
    );
  }
}
